package com.tian.controller.api;

import com.tian.annotation.LoginCheckAnnotation;
import com.tian.common.CommonResult;
import com.tian.dto.*;
import com.tian.service.ChargeRecordService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * {@code @description:} 充电业务API接口
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-08-29 17:13
 * {@code @version:} 1.0
 */
@RestController
@RequestMapping("/charging")
public class AppChargingController {
    @Resource
    private ChargeRecordService chargeRecordService;

    @LoginCheckAnnotation
    @PostMapping("/start")
    public CommonResult<Boolean> startCharging(@RequestBody ChargingStartReqDto chargingStartReqDto) {
        return chargeRecordService.startCharge(chargingStartReqDto);
    }

    @LoginCheckAnnotation
    @PostMapping("/stop")
    public CommonResult<ChargeRecordRespDto>  stopCharging() {
        return chargeRecordService.doStopCharge();
    }

    /**
     * 用户充电记录list
     */
    @LoginCheckAnnotation
    @PostMapping("/record/list")
    public CommonResult<ChargeRecordPageRespDto> getChargeRecordList(@RequestBody ChargeRecordPageReqDto chargeRecordPageReqDto) {
        return chargeRecordService.getChargeRecordList(chargeRecordPageReqDto);
    }
}
